Skip to content

fix(audit): make the release-boundary check reproducible and stop it failing on its own fixture - #3

Merged
mxuanvan02 merged 1 commit into
mainfrom
fix/release-boundary-audit-20260922
Sep 22, 2026
Merged

mxuanvan02 merged 1 commit into
mainfrom
fix/release-boundary-audit-20260922

Conversation

@mxuanvan02

Copy link
Copy Markdown
Owner

Why

tools/machine_semantic_audit.py reported FAIL with 18 findings on a clean
clone
, while the committed receipt machine-policy-audit.json claimed PASS,
0 findings, 52 files
— against a tree that actually holds 218 files. Both
sides were wrong. Three defects, each verified by measurement before the fix.

This is the follow-up I flagged in PR #1 and PR #2 rather than mixing into them.
Neither earlier PR changed the finding count (measured 18 → 18), so the defect
predates both.

1. The audit flagged its own rights-cleared fixture

The 18 PNGs under experiments/six_arm/dataset/images/ are synthetic and are
not source-derived. Measured, not inferred from the filename:

property value what a real crop would look like
dimensions 96×96 RGB, all 18 varies with page region
IDAT vs raw 27760 / 27648 bytes —
compression ratio 0.996 5–50× for a page or figure crop
distinct colours 9210–9215 per 9216 px heavy reuse; a line diagram uses tens

Incompressible noise with nearly every pixel a unique colour is generated
pixels, not a scan. dataset/dataset_manifest.json additionally binds all 18 by
sha256 and byte size (0 mismatches) and declares the set "Rights-cleared
synthetic contract fixture; not the empirical study corpus."

So untracking was the wrong fix: removing the images would break a
content-bound fixture. They are allow-listed instead — individually, not by
directory
, so an unexpected 19th image there still raises unexpected_media.
The rationale and the measurements are recorded in a comment at the allow-list
so the next reader does not have to redo this.

2. The receipt was hashed into its own digest, so it could never be accurate

Writing the receipt changed the digest it records. Iterating write → audit four
times produced four different digests and never converged:

iter0: digest=0e174619a49b53cdaff7
iter1: digest=23447be423959e301d5a
iter2: digest=153501e467fa519c219d
iter3: digest=69b76d7ca798c26cfad8

A committed receipt is therefore unsatisfiable by construction — which is
exactly why the stale one survived unnoticed. The receipt is now excluded from
the digest input only.

It is still scanned. Excluding it from scanning as well was my first attempt
and a mutation test rejected it: a forbidden token placed inside the receipt
stopped being flagged. The exclusion is scoped to the digest, and the mutation
table below pins that.

3. A directory exclusion containing a separator could never match

The exclusion set is compared against p.parts, whose components never contain
a slash — so the literal "src/ecm_tqag.egg-info" excluded nothing. After
pip install -e . the egg-info files entered the digest:

clean tree : files=218 digest=2d0ac94d... PASS
after build: files=224 digest=60140bec... PASS   <- digest changed

A reviewer following README §7 after installing the package computed a
different digest from the committed receipt, so the receipt was
irreproducible
— and README §7 explicitly tells them to regenerate it.
Exclusions now match per path component via EXCLUDED_PARTS, and the digest is
stable under build artifacts (measured: 218 files both ways).

Verification

Every claim above was measured on this tree before committing.

Mutation-verified, because a check never observed red is not evidence:

mutation expected observed
add a 19th undeclared PNG FAIL exit 1, unexpected_media on that file
forbidden token in a new .md FAIL exit 1, forbidden_baseline
forbidden token inside the receipt FAIL exit 1, flagged against the receipt
create src/ecm_tqag.egg-info/ (6 files) digest unchanged digest unchanged, 218 files
create .pytest_cache/junk.txt digest unchanged digest unchanged
remove every mutation PASS exit 0, 0 findings

CI steps reproduced locally in a fresh venv, matching .github/workflows/ci.yml:
pytest → exit 0 (35 passed, 2 skipped); ecm-tqag validate fixtures/packages
→ exit 0; audit → exit 0, PASS, 0 findings over 218 files.

The receipt is regenerated and reproduces exactly, including after an editable
install
— which is the specific failure being fixed.

Not changed

semantic_validation stays false, and the audit still checks strings and file
classes only. A PASS here means no unexpected media and no forbidden string was
found
— not that any semantic or rights claim was validated. The tool's own
docstring says so and that boundary is unchanged.

…failing on its own fixture

`tools/machine_semantic_audit.py` reported FAIL with 18 findings on a clean
clone, and the committed receipt claimed PASS with 0 findings over 52 files while
the tree holds 218. Three defects, each verified by measurement before the fix.

1. The audit flagged its own rights-cleared fixture.
   The 18 PNGs under `experiments/six_arm/dataset/images/` are synthetic and are
   not source-derived: all are 96x96 RGB with IDAT 27760 of 27648 raw bytes
   (compression ratio 0.996) and 9210-9215 distinct colours per 9216 pixels.
   That is incompressible noise; a page or figure crop compresses 5-50x and
   reuses colours heavily. Each file is content-bound by sha256 and byte size in
   `dataset/dataset_manifest.json` (all 18 verified, 0 mismatches), and that
   manifest declares the set a rights-cleared synthetic contract fixture, so
   untracking the images would break the fixture rather than improve the
   boundary. They are allow-listed instead, individually rather than by
   directory, so an unexpected 19th image in that directory still raises
   `unexpected_media`.

2. The receipt was hashed into its own digest, so it could never be accurate.
   Writing the receipt changed the digest it records; iterating write/audit four
   times produced four different digests and never converged. A committed
   receipt is therefore unsatisfiable by construction, which is why the stale
   one survived unnoticed. The receipt is now excluded from the digest input
   only. It is still scanned for forbidden strings and secrets like any other
   text file -- excluding it from scanning as well was tried first and rejected
   by mutation test (a forbidden token placed inside the receipt stopped being
   flagged).

3. A directory exclusion containing a separator could never match.
   The exclusion set is compared against `p.parts`, whose components never
   contain a slash, so the literal `"src/ecm_tqag.egg-info"` excluded nothing.
   After `pip install -e .` the egg-info files entered the digest: measured
   `2d0ac94d...` (218 files) clean versus `60140bec...` (224 files) built. A
   reviewer following README section 7 after installing the package computed a
   different digest from the committed receipt, so the receipt was
   irreproducible. Exclusions now match per path component via
   `EXCLUDED_PARTS`.

The receipt is regenerated and now reproduces exactly, including after an
editable install.

Mutation-verified, because a check never observed red is not evidence:

| mutation | expected | observed |
| --- | --- | --- |
| add a 19th undeclared PNG | FAIL | exit 1, `unexpected_media` on that file |
| forbidden token in a new .md | FAIL | exit 1, `forbidden_baseline` |
| forbidden token inside the receipt | FAIL | exit 1, flagged against the receipt |
| create `src/ecm_tqag.egg-info/` (6 files) | digest unchanged | digest unchanged, 218 files |
| create `.pytest_cache/junk.txt` | digest unchanged | digest unchanged |
| remove every mutation | PASS | exit 0, 0 findings |

CI steps reproduced in a fresh venv: `pytest` exit 0 (35 passed, 2 skipped);
`ecm-tqag validate fixtures/packages` exit 0; audit exit 0, PASS, 0 findings.

Not changed: `semantic_validation` stays `false`, and the audit still checks
strings and file classes only. A PASS here means no unexpected media and no
forbidden string was found, not that any semantic or rights claim was validated.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mxuanvan02
mxuanvan02 merged commit cf42bb3 into main Sep 22, 2026
7 checks passed
@mxuanvan02
mxuanvan02 deleted the fix/release-boundary-audit-20260922 branch September 22, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant